import re

from Code.XmlDataOperation import XmlDataOperation
import pandas as pd
class XmlDataOperationCSV(XmlDataOperation):
    def __init__(self):
        super().__init__()

    def handle_file(self, path):
        data = pd.read_csv(path)
        data = data.astype(str)
        dataDic = {}
        for i in range(0, len(data)):
            for j in range(0, len(data.iloc[i])):
                className = data.iloc[i][j]
                #找到字母和数字的组合的列
                if re.match('^(?=.*[0-9] $ )(?=.*[a-zA-Z])', className):
                    #print(className)
                    if className in dataDic.keys():
                        dataDic[className] = dataDic[className] + 1
                    else:
                        dataDic[className] = 1
        return dataDic


